package com.ciwong.epaper.widget;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * Created by keepon on 2018/8/8.
 */
public class ObservableNestedScrollView extends ScrollView {
	private ScrollViewListener scrollViewListener = null;
	public ObservableNestedScrollView(@NonNull Context context) {
		super(context);
	}

	public ObservableNestedScrollView(@NonNull Context context, @Nullable AttributeSet attrs) {
		super(context, attrs);
	}

	public ObservableNestedScrollView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}

	@Override
	protected void onScrollChanged(int x, int y, int oldx, int oldy) {
		super.onScrollChanged(x, y, oldx, oldy);
		if (scrollViewListener != null) {
			scrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
		}
	}
	public void setScrollViewListener(ScrollViewListener scrollViewListener) {
		this.scrollViewListener = scrollViewListener;
	}

	public interface ScrollViewListener {

		void onScrollChanged(ObservableNestedScrollView scrollView, int x, int y, int oldx, int oldy);

	}
}
